package cn.jsj.hzu.qm.facecloud.user.dao.impl;

import java.util.List;

import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;

import cn.jsj.hzu.qm.facecloud.user.dao.AppDao;
import cn.jsj.hzu.qm.facecloud.user.pojo.App;
import cn.jsj.hzu.qm.facecloud.user.pojo.User;

public class AppDaoImpl implements AppDao {

	JdbcTemplate jdbcTemplate = null;

	public JdbcTemplate getJdbcTemplate() {
		return jdbcTemplate;
	}

	public void setJdbcTemplate(JdbcTemplate jdbcTemplate) {
		this.jdbcTemplate = jdbcTemplate;

		// 666
	}

	@Override
	public int getAllAppNum() {
		String sql = "SELECT COUNT(*) FROM tb_app";
		try {

			int i = jdbcTemplate.queryForObject(sql, Integer.class);
			return i;
		} catch (Exception e) {
			e.printStackTrace();
		}

		return -1;
	}

	@Override
	public int addApp(App app) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public int deleteApp(App app) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public int updateApp(App app) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public App findAppById(int id) {
	
		String sql = "SELECT * FROM tb_app WHERE id =?";
		try {
			App app = jdbcTemplate.queryForObject(sql, new BeanPropertyRowMapper<>(App.class), new Object[] {id});
			return app;
		} catch (Exception e) {
			e.printStackTrace();
		}
		return null;
	}

	@Override
	public List<App> findAppByUserId(int userId) {
		// TODO Auto-generated method stub
		return null;
	}

}
